package com.hirsi.module.menu.vo.result;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.hirsi.core.expand.TreeNode;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;
import java.util.Map;

@ApiModel("菜单操作权限")
@Data
public class PermissionResult {

    @ApiModelProperty("菜单权限集合")
    private List<MenuPermission> menuPermissions;

    @ApiModelProperty(value = "操作权限", position = 1)
    private Map<String, List<OperatePermission>> operatePermissions;

    @ApiModel("菜单权限")
    @Data
    public static class MenuPermission implements TreeNode<MenuPermission, Integer> {

        @ApiModelProperty("菜单地址")
        private String url;

        @ApiModelProperty(value = "菜单名称", position = 1)
        private String name;

        @ApiModelProperty(value = "菜单图标", position = 2)
        private String icon;

        @ApiModelProperty(value = "下级菜单", position = 3)
        private List<MenuPermission> children;

        @ApiModelProperty(hidden = true)
        @JsonIgnore
        private Integer id;

        @ApiModelProperty(hidden = true)
        @JsonIgnore
        private Integer pid;

        @ApiModelProperty(hidden = true)
        @JsonIgnore
        private Integer type;

        @ApiModelProperty(hidden = true)
        @JsonIgnore
        private Integer showPosition;

        @Override
        public Integer getNodeId() {
            return id;
        }

        @Override
        public Integer getParentNodeId() {
            return pid;
        }
    }

    @ApiModel("操作权限")
    @Data
    @AllArgsConstructor
    @NoArgsConstructor
    public static class OperatePermission {

        @ApiModelProperty("操作事件")
        private String click;

        @ApiModelProperty(value = "操作名称", position = 1)
        private String name;

        @ApiModelProperty(value = "图标", position = 2)
        private String icon;

        @ApiModelProperty(value = "显示位置：0-工具栏，1-行", position = 3)
        private Integer showPosition;
    }
}
